<fieldset>
    <div class="toolbar"><?php echo $this->element('toolbar', array('buttons' => array('search', array('refresh' => array('action' => 'history_display/' . $user_id . '/refresh:true', 'update' => 'userHistory'))))); ?></div>
    <legend>User History</legend>
    <input type="hidden" id="UserHistoryUserId" name="data['UserHistory']['user_id']" value="<?php echo $user_id; ?>" />
    <?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
    <?php echo $this->element('dataNotFound'); ?>
    <? else : // ถ้ามีข้อมูล ?>
        <?php $paginator->options(array('url' => $this->passedArgs, 'update' => 'userHistory', 'indicator' => 'indicator')); ?>
        <?php echo $this->element('dataCaptionLimit', array('action' => 'history_display/' . $user_id, 'update' => 'userHistory')); ?>
        <?php $cur = $paginator->counter(array('format' => '%start%')); ?>
    <table class="data">
        <thead>
            <tr>
                <th class="no"><?php echo $paginator->sort('No', 'id'); ?></th>
                <th><?php echo $paginator->sort('Log in date', 'log_in_time'); ?></th>
                <th><?php echo $paginator->sort('Log in time', 'log_in_time'); ?></th>
                <th><?php echo $paginator->sort('Log out date', 'log_out_time'); ?></th>
                <th><?php echo $paginator->sort('Log out time', 'log_out_time'); ?></th>
            </tr>
        </thead>
        <tbody>
                <?php $i = 0; foreach($this->data as $key => $data): ?>
                    <?php
                    $tableCell = array();
                    $tableCell[] = ++$i;
                    $tableCell[] = empty($data['UserHistory']['log_in_time'])? '-': date('d/m/Y', strtotime($data['UserHistory']['log_in_time']));
                    $tableCell[] = empty($data['UserHistory']['log_in_time'])? '-': date('H:i:s', strtotime($data['UserHistory']['log_in_time']));
                    $tableCell[] = empty($data['UserHistory']['log_out_time'])? '-': date('d/m/Y', strtotime($data['UserHistory']['log_out_time']));
                    $tableCell[] = empty($data['UserHistory']['log_out_time'])? '-': date('H:i:s', strtotime($data['UserHistory']['log_out_time']));
                    echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
                    ?>
                <?php endforeach; ?>
        </tbody>
    </table>
    <?php endif; ?>
</fieldset>
